home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-09-16 | 2.3 KB | 77 lines | [TEXT/PJMM] |
-
- PROGRAM EnableSoundThrough;
- { Demonstrating how to enable input sound playthrough }
- { on a LC enabling playthrough kills sound output, on a si you can play back at the same time }
-
- CONST
- siReadPermission = 0; { permission passed to SPBOpenDevice }
- siWritePermission = 1;
- siPlayThruOnOff = 'plth'; { playthrough state for SPBGetDeviceInfo and SPBSetDeviceInfo }
-
- VAR
- err: OSErr;
- sInRef: LONGINT;
- volume: Integer;
-
- { These functions are declared in SoundInput.p (and equivalent files.) I am declaring them }
- { here for nothing sake, O.K.? }
- FUNCTION SPBOpenDevice (deviceName: Str255; permission: INTEGER; VAR inRefNum: LONGINT): OSErr;
- INLINE
- $203C, $0518, $0014, $A800;
-
- FUNCTION SPBGetDeviceInfo (inRefNum: LONGINT; infoType: OSType; infoData: Ptr): OSErr;
- INLINE
- $203C, $0638, $0014, $A800;
-
- FUNCTION SPBSetDeviceInfo (inRefNum: LONGINT; infoType: OSType; infoData: Ptr): OSErr;
- INLINE
- $203C, $063C, $0014, $A800;
-
- FUNCTION SPBCloseDevice (inRefNum: LONGINT): OSErr;
- INLINE
- $203C, $021C, $0014, $A800;
-
- PROCEDURE GetPlayThroughVolume;
- BEGIN
- err := SPBGetDeviceInfo(sInRef, siPlayThruOnOff, @volume); { What is the current volume? }
- IF err = noErr THEN
- writeln('no problem getting play through volume =', volume)
- ELSE
- writeln('could not get play through volume, err = ', err);
- END;
-
- PROCEDURE OnOffSoundThrough;
- BEGIN
- IF volume = 0 THEN { If playthrough volume is 0 (off) then we turn it on }
- volume := 5
- ELSE { if we have sound comming in we will kill it }
- volume := 0;
- err := SPBSetDeviceInfo(sInRef, siPlayThruOnOff, @volume);
- IF err = noErr THEN
- writeln('no problem setting play through, volume is ', volume)
- ELSE
- writeln('could not set play through, err = ', err)
- END;
-
- BEGIN
- ShowText;
- err := SPBOpenDevice('', siWritePermission, sInRef); { Null string means default device }
- IF err = noErr THEN
- BEGIN
- writeln('No problem opening device');
- GetPlayThroughVolume; { get current level }
- OnOffSoundThrough; { flip it }
- GetPlayThroughVolume; { make sure it worked }
- END
- ELSE
- WriteLn('Problem when calling SPBOpenDevice, err = ', err);
- WHILE NOT button DO
- ;
- IF sInRef <> 0 THEN
- BEGIN
- OnOffSoundThrough; { flip it }
- err := SPBCloseDevice(sInRef); { We opened it so lets close it }
- IF err <> noErr THEN
- DebugStr('Error closing the input device');
- END;
- END.